/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
/**
 * 
 * If you have edited the file, please update
 * all the last-modified fields manually. Thanks!
 *
 * @last-modified by: 
 * @last-modified date: 
 * @last-modified time: 
 *
 * @author Swee Zhi
 * @date-created Sep 23, 2011    @time-created 5:02:02 PM
 *
 * @project: 
 * @module: 
 * @institution: 
 *
 */
package util.generator;

import java.util.Random;

public class PasswordGenerator {
    private Random randomVal = null;
    private byte decision, numValue;
    private char charValue;
    
    public PasswordGenerator() {
        randomVal = new Random();
    }
    
    public String generatePassword(int length){
        StringBuilder sb = new StringBuilder();
        while(sb.length() < length) {
            decision = (byte)randomVal.nextInt(2);
            numValue = (byte)randomVal.nextInt(10);
            charValue = (char)(randomVal.nextInt(25) + 65);
            sb.append( (decision%2 == 0) ? ( charValue + "" ) : ( numValue + "") );
        }
        return sb.toString();
    }
    
}

